package com.jdls.web;

import com.jdls.pojo.Brand;
import com.jdls.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 嘉德罗斯
 * @date 2021/8/31
 */
@WebServlet("/SelectByIDServlet")
public class SelectByIDServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8"); // 处理请求参数的乱码
        response.setContentType("text/html;charset=utf-8"); // 处理响应数据的乱码
        String id = request.getParameter("id");
        int i = Integer.parseInt(id);
        BrandService service = new BrandService();
        Brand brand = service.selectByID(i);
        request.setAttribute("brand",brand);
        request.getRequestDispatcher("/Update.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
